<?php

/**
 * StoreSettings actions.
 *
 * @package    ProdAssistant
 * @subpackage StoreSettings
 * @author     Paweł Świtalla
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class StoreSettingsActions extends sfActions
{
  public function executeSet(sfWebRequest $request)
  {
    $values = $request->getParameter('settings_values');
    if($request->isMethod('post'))
    {
      $user = $this->getUser()->getAttribute('userObject');
      if(Settings::saveUserSettings($values, $user))
      {
        $this->getUser()->setFlash('info', 'Ustawienia zapisane.');
        if($request->isXmlHttpRequest())
        {
          return sfView::NONE;
        }
        else $this->redirect($request->getReferer());
      }
      else
      {
        if($request->isXmlHttpRequest())
        {
          $this->getResponse()->setContent('error@Wystąpił błąd podczas zapisu ustawień.#');
          return sfView::NONE;
        }
      }
    }
  }
  
  public function executeIndex(sfWebRequest $request)
  {
    $this->setLayout(PACore::getLayoutsDir()."/clear");
  }
  
  public function executeCategories(sfWebRequest $request)
  {
    
  }
}
